﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AirManager.Entities;
using FluentNHibernate.Mapping;

namespace AirManager.Repository
{
    public class FleetMap : ClassMap <Fleet>
    {
        public FleetMap()
        {
            //UseUnionSubclassForInheritanceMapping();

            Id(x => x.Id).Column("FleetID").GeneratedBy.Identity();
            Map(x => x.Nome).Column("Nome").Length(200).Not.Nullable();
            HasMany(m => m.Fixes).LazyLoad().Cascade.All().KeyColumn("FleetID").Inverse().Cascade.AllDeleteOrphan();
            HasManyToMany(m => m.Pilots)
                .AsBag()
                .Table("FleetPilot")
                .ChildKeyColumn("PilotID")
                .ParentKeyColumn("FleetID")
                .Inverse()
                .Cascade.SaveUpdate()
                .Cascade.Delete()
                .Cascade.All();



                
                
        }

    }
}
